{% extends "data_list.html" %}
{% load i18n %}
{% block headjs %}
<script type="text/javascript" src="/media/jslib/consumeReport.js"></script>
{% endblock %}
{% block getdatalist %}
{% endblock %}


{% block export %}
	<input type="hidden" id="id_all_emp" value="all"/>
	{% if request.user|HasPerm:"pos.can_consumeAppReport" %}
		<li id="id_li_export">
			<div id="id_model_export"><a href="javascript:void(0)"><span class="action_export"></span>{% trans "导出" %}</a></div>
			<div class='div_leftBottomLine'></div>
		</li>    
   {% endif %} 
{% endblock %}


{% block addjs %}
 {%if request.user|HasPerm:"contenttypes.can_consumeAppReport"%}
 var dbapp_url="{{dbapp_url}}";
{%if "POS_IC"|filter_config_option%}
$(".icon_help_current").attr("href",$(".icon_help_current").attr("href").replace("consume","ic_consume"));
{%endif%}

function getPubOpt(app,model,where,report_type)
{
	{%if "POS_IC"|filter_config_option%}
		switch(report_type)
		{
			case 1://充值
				hide_col = ['UserID_id','discount','allow_type','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','type.type']
				break;
			case 5://退款
				hide_col = ['UserID_id','discount','allow_type','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','type.type']
				break;
			case 2://补贴
				hide_col = ['UserID_id','discount','sn_name','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','type.type']
				break;
			case 7://发卡表
				hide_col = ['UserID_id','discount','sn_name','allow_type','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','type.type','log_flag','money','blance','convey_time']
				break;
			case 4://退卡表
				hide_col = ['UserID_id','discount','sn_name','allow_type','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','type.type','log_flag','money','blance','convey_time']
				break;
			case 10://卡成本表
				hide_col = ['UserID_id','discount','sn_name','allow_type','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','type.type','log_flag','blance','convey_time']
				break;
			default:
				hide_col = ['UserID_id','discount','sn_name','allow_type','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','type.type','log_flag','convey_time']
				break;
		}
	{%else%}
		hide_col = ['UserID_id','discount','sn_name','allow_type','serialnum','UserID.pk','get_attpic','dining.code','dining.name','cardstatus','log_flag']
	{%endif%}
	var pubopt={
		dbapp_url:"{{dbapp_url}}", 
		model_url:"{{dbapp_url}}"+app+"/"+model+"/",                      //根目录地址
		record_per_page: 15,                 //每页记录数
		max_no_page: 50,                 //记录数少于该数据时，不分页显示
		row_operations: false,               //对象操作true表示全部显示(默认)，false表示全部不显示，对象表示操作["New","Delete",["Leave",...]]
		obj_edit:false,
		disabled_actions: ['_add','_delete','_clear'],
		model_actions:false,
		object_actions:false,
		scrollable:{heigh:340},
		disable_cols:hide_col,
		obj_edit:false,
		init_query:where	
	}
	return pubopt;
}

function getPubOpt_lost(app,model,where) //卡挂失
{
	var pubopt={
		dbapp_url:"{{dbapp_url}}", 
		model_url:"{{dbapp_url}}"+app+"/"+model+"/",                      //根目录地址
		record_per_page: 15,                 //每页记录数
		max_no_page: 50,                 //记录数少于该数据时，不分页显示
		row_operations: false,               //对象操作true表示全部显示(默认)，false表示全部不显示，对象表示操作["New","Delete",["Leave",...]]
		obj_edit:false,
		disabled_actions: ['_add','_delete','_clear'],
		model_actions:false,
		object_actions:false,
		scrollable:{heigh:340},
		disable_cols:['UserID_id','UserID.pk','get_attpic','blance'],
		obj_edit:false,
		init_query:where	
	}
	return pubopt;
}


function getDataOpt(datajson,url)
{
	
	hiddencol=["userid","data_verbose_column"]
	var data=[]
	var fn=datajson.fieldnames;
	
	
	for(var j=0;j<datajson.datas.length;j++)
	{
		var td=datajson.datas[j];
		var tmp=[]
		for(var i=0;i<fn.length;i++)
		{			
			tmp.push(encodeTxt(td[fn[i]]));			
		}
		data.push(tmp);
	}
	var opt={
	  heads:datajson.fieldcaptions,//是一个列表，表示显示在列表表头上的文字; 
	  fields:datajson.fieldnames,//是一个列表，表示显示在列表表头上的文字; 
	  data:data,//二维列表，表示多行的数据；
	  disable_cols:hiddencol,//不可见的列
	  key_field:"id",  //关键字段名
	  data_verbose_column:"", //数据显示字段名，为空字符串
	  show_head: true,//显示头
	  actions: {},//是一个对象，表示定义在该数据模型上的操作列表，其每一个操作是一个json对象
	  base_url: "", //表示当前数据页面的URL; 
	  row_operations: [],//为一个列表，表示要放在对当前记录进行的操作栏的操作名（字符串）
	  multiple_select: null,//是否多选
	  page_count: datajson.page_count, //每页显示的数据行
	  current_page: datajson.page, //页号
	  record_count: datajson.item_count, //如果为零，则不在页面上显示总记录数
	  layout: "table",
	  scrollable:{heigh:340},
	  grid_name:"",//记录的名字
	  tbl_id:"id_tbl",//"table"-表格形式显示, "icon"-大图标形式显示, "compact"-小图标形式显示 
	 // a_div:$('<div class="action Link_blue1"></div>'),//默认操作的div
	 // p_div:$('<div  class="pages floatR Link_blue2"></div>'),//默认放置分页的div
	  //t_div:$('<div class="list_outBox"></div>'),//默认放置列表的div
	 // grid_div:$('<div class="grid clearL"></div>'),//整个控件默认的div
	  on_pager:function(grid,p){  			  		
	  		var gd=grid;	  		
	  		$("#id_calculateform").append("<input type='hidden' name='p' value='"+p +"' \>");
	  		if($("#id_calculateform").find("input[name='pa']").length==0)	  
	  			$("#id_calculateform").append("<input type='hidden' name='pa' value='T' \>");
	  		var u_url=url	
	  		var option={
				url:u_url,	
				dataType:"json",					
				type:"POST",
				success:function(data){	
					$.extend(gd.g,getDataOpt(data,u_url));									
					gd.g.reload_data();					
				}
			}
			$("#id_calculateform").ajaxSubmit(option);
			$("#id_calculateform").find("input[name='p']").remove();
	  	return false;
	  }
	};
	
	return opt

	
	
}

function show_hall(data)
{

    if(data.halls != "")
    {   
        for(a in data.halls)
        {
            $("#monitor_hall select").append('<option value="'+data.halls[a][0]+'">'+data.halls[a][1]+" "+data.halls[a][2]+'</option>');
        }
		
    }
	if(data.meals !="")
	{
		for(m in data.meals)
		{	
			$("#monitor_meal select").append('<option value="'+data.meals[m][0]+'">'+data.meals[m][1]+" "+data.meals[m][2]+'</option>');
		}
	
	}
	if(data.operates !="")
	{
		for(m in data.operates)
		{	
			$("#monitor_operate select").append('<option value="'+data.operates[m][1]+'">'+data.operates[m][1]+'</option>');
		}
		
	}
}

function Query_Load(url)
{
	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		async: false,
		success: function(data)
		{
//		  {%if "POS_IC"|filter_config_option%}
//			show_hall(data)
//		   {%endif%}
		   if(data.operates !="")
			{
				for(m in data.operates)
				{	
					$("#monitor_operate select").append('<option value="'+data.operates[m][1]+'">'+data.operates[m][1]+'</option>');
				}
				
			}
			if(data.operate_card !="")
				{
					for(m in data.operate_card)
					{	
						$("#monitor_operate select").append('<option value="'+data.operate_card[m][1]+'">{% trans '操作卡' %}'+data.operate_card[m][1]+'</option>');
					}
					
				}
			
			if(data.halls != "")
			   {   
			       for(a in data.halls)
			       {
			           $("#monitor_hall select").append('<option value="'+data.halls[a][0]+'">'+data.halls[a][1]+" "+data.halls[a][2]+'</option>');
			       }
				
			   }
			
			
		   
		}
	});        
}
var stamp = new Date().getTime();
url = "/{{ request.surl }}pos/getdiningroom/?stamp="+ stamp;

$(document).ready(function(){Query_Load(url)})
{% else %}
        alert(gettext("对不起，您没有访问该页面的权限，不能浏览更多信息！"));
        window.location.href="/{{ request.surl }}accounts/login/";
    {% endif %}


{% endblock %}*/


{% block op_for_tab %}

{% endblock %}

<style>
.calculatediv{
	width:300px;
	overflow:auto;
	}
</style>
{% block content %}
{% endblock %}
{% block content_end %}
<div style="margin:35px 10px 10px 115px;">


<input type="hidden" id="id_current_report" value="1" />
<div id="id_divsearch" class="calculate_divsearch">
	<div class="clearB" style="margin:5px 0px;">
    <form id="id_calculateform" method="post">
    	<table>
    	 <tr style="vertical-align:middle">
			
		{% autoescape off %}
			<td><div id="emp_labor">{{empfield|field_as_label_tag}}<div></td><td><div id="show_emp_tree">{{empfield.as_widget}}</div></td>
		{% endautoescape %}
		
			<td><div id="monitor_cometime">{% trans '开始日期' %}</div></td><td><div id="div_cometime"><input type="text" style="width:90px;" class="date dp-applied" format="yyyy-MM-dd"  readonly="True" name="ComeTime" id="id_cometime"/></td></div>
			<td><div id="monitor_endtime">{% trans '结束日期' %}</div></td><td><div id="div_endtime"><input type="text" style="width:90px;" class="date dp-applied" format="yyyy-MM-dd"  readonly="True" name="EndTime" id="id_endtime"/></td></div>
			 
			<td><div id="monitor_hall" style="display: none;"><label>{% trans "餐厅" %}</label><select style="width:80px"><option value="0">{% trans "全部餐厅" %}</option></select>&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
			<!--<td><div id="monitor_meal"><label>{% trans "餐别" %}</label><select style="width:80px"><option value="0">{% trans "全部餐别" %}</option></select>&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
			 -->
			<td><div id="monitor_operate"><label >{% trans "操作员" %}</label><select style="width:80px"><option value="9999">{% trans "全部" %}
			{%if "POS_IC"|filter_config_option%}
			<option value="0">{% trans "机器数据" %}</option>
			{%endif%}
			</option></select>&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
			{%if "POS_IC"|filter_config_option%}
			<td><div id="monitor_pos_model"><label for="id_pos_model" >{% trans "消费模式" %}</label><select id="search_id_pos_model" name="" fieldname="pos_model">
			<option value="0">全部</option>
			<option value="1">定值模式</option>
			<option value="2">金额模式</option>
			<option value="3">键值模式</option>
			<option value="4">计次模式</option>
			<option value="5">商品模式</option>
			<option value="6">计时模式</option>
			<option value="7">记账模式</option>
			<option value="9">设备纠错</option>
			<option value="8">手工补消费</option>
			</select></div></td>
		 	{%endif%}
		 	<!--<td><div style="margin:-3px 0px 0px 5px;"><span class="action_Search">&nbsp;</span><a id="id_query" href="#" class="Link_blue1" >{% trans '查询' %}</a></div></td>
			<td><div style="margin:-3px 0px 0px 5px;"><span class="action_calculate">&nbsp;</span><a id="id_calculate" href="javascript:void(0)" class="Link_blue1">{% trans '统计' %}</a></div></td>
         -->
        
        
		</tr>
		<tr><td colspan="3">
        <div id="id_ReturnMsg" class="div_ReturnMsg"></div></td>
        </tr>
        </table>
        <input type="hidden" name="DeptIDs" value="" />
        <input type="hidden" name="isForce" value="0" />
        <input type="hidden" name="UserIDs" value="" />
    </form>
  
	</div>
</div>
<div id="calculatetabs"><!--height:440px;overflower:auto-->
	    <ul class="tabs">
			<li><a href="#caltabs-7" onClick="IssueCard('')">{% trans '发卡表' %}</a></li>
			<li><a href="#caltabs-8" onClick="ChargeRecord('')">{% trans '充值表' %}</a></li>
			<li><a href="#caltabs-1" onClick="posReimburese('')">{% trans '退款表' %}</a></li>
			<li><a href="#caltabs-10" onClick="Allowance('')">{% trans '补贴表' %}</a></li>
			<li><a href="#caltabs-6" onClick="ReturnCard('')">{% trans '退卡表' %}</a></li>
			<li><a href="#caltabs-2" onClick="posCarCost('')">{% trans '卡成本表' %}</a></li>
			<li><a href="#caltabs-3" onClick="CarBalanceReport('')">{% trans '卡余额表' %}</a></li>
			{%if "POS_IC"|filter_config_option%}
				<li><a href="#caltabs-15" onClick="NOCarBalanceReport('')">{% trans '无卡退卡表' %}</a></li>
			{%endif%}
			<li><a href="#caltabs-11" onClick="ManageCard('')">{% trans '管理卡表' %}</a></li>
			<li><a href="#caltabs-4" onClick="posLostCard('')">{% trans '挂失/解挂表' %}</a></li>
			{%if "POS_IC"|filter_config_option%}
				<li><a href="#caltabs-12" onClick="pos_error_data('')">{% trans '异常消费明细表' %}</a></li>
			{%endif%}
			
			{%if "POS_ID"|filter_config_option%}
				<li><a href="#caltabs-5" onClick="posReplenishCard('')">{% trans '换卡表' %}</a></li>
			{% endif %}
			<li><a href="#caltabs-9" onClick="FlushCard_ic('')">{% trans '消费明细表' %}</a></li>
			
			
	    </ul>
		<div  class="calculatediv" id="caltabs-7">
			<div id="subtabs-7">        
			</div>
		</div>
        <div class="calculatediv" id="caltabs-8" >
			<div id="subtabs-8">
        
			</div>
		</div>
		<div class="calculatediv" id="caltabs-1"  >
				<div id="subtabs-1">
		       
				</div>
			</div>	
		
        <div class="calculatediv" id="caltabs-10" >
			<div id="subtabs-10">
        
			</div>
		</div>
        <div class="calculatediv" id="caltabs-6" >
			<div id="subtabs-6">
        
			</div>
		</div>
       
		
		<div class="calculatediv" id="caltabs-2" >
			<div id="subtabs-2">		
			</div>
		</div>
		<div class="calculatediv" id="caltabs-3" >
			<div id="subtabs-3">		
			</div>
		</div>
		{%if "POS_IC"|filter_config_option%}
		<div class="calculatediv" id="caltabs-15" >
			<div id="subtabs-15">		
			</div>
		</div>
		{%endif%}
		<div class="calculatediv" id="caltabs-11" >
					<div id="subtabs-11">
		        
					</div>
				</div>
		
		<div class="calculatediv" id="caltabs-4" >
			<div id="subtabs-4">		
			</div>
		</div>
		{%if "POS_IC"|filter_config_option%}
			<div class="calculatediv" id="caltabs-12" >
				<div id="subtabs-12">
				</div>
			</div>
		{%endif%}
		{%if "POS_ID"|filter_config_option%}
			<div class="calculatediv" id="caltabs-5" >
				<div id="subtabs-5">		
				</div>
			</div>
		{%endif%}
		<div class="calculatediv" id="caltabs-9" >
			<div id="subtabs-9">		
			</div>
		</div>
		
		<div class="calculatediv" id="caltabs-11" >
			<div id="subtabs-11">
			</div>
		</div>
		
		
</div>
{%if "POS_IC"|filter_config_option%}
<div id="id_posexcept_desc" style="display: none;"><span >{% trans "消费日期异常解释:" %}</span><span style = 'font-weight:bold;' class="color_orange">{% trans "（情况一）：系统使用过程中，设备时间发生错乱，导致员工的消费时间小于发卡日期！这种情况产生的异常记录不会影响账目结算结果。" %}<br/>{% trans "（情况二）：系统正式上线使用前，消费机中存在测试记录！实际消费金额计算公式：消费金额=实消费总额 — 异常合计总额" %}</span></div>
{% endif %}
</div>
{% endblock %}
